/**
 * 攻略页面
 */
var App = require("../libs/network/mvr.js");
var Imports = require("../libs/utils/imports.js");
var Template = require("../libs/plugins/art-template.js");
var XData = require("../libs/gamepump/xdata.js");
var NativeApp = require("../libs/phonegap/native-bridge.js");
var Url = require("../libs/utils/url.js");
var Cfg = require("../libs/base-conf.js");
var Stat = require("../libs/utils/stat.js");

var conTpl = Imports("text!../page-layout/guide/container.html");
var guideTpl = Imports("text!../page-layout/guide/list.html");

var section = $("#dt-content");
section.append(conTpl);
var container = section.find("ul");

container.on('tap', 'li a', function(e){
    var url = $(e.currentTarget).attr('data-url');
    if(url){
        var newId= url.substring(url.indexOf("=")+1,url.length);
        Stat.addActionStat("detail_news","gl",newId);
        Url.gotoPage(url);
        e.preventDefault();
        return false;
    }
});

App.addModule("GuideList",
    App.Model.extend({
        'key': "4010",                   //数据协议keycode,末尾带0列表以此栏目作为分页标识
        'private': 1,                    //是否走专属通道传递参数
        'params': "pcount=10&gid=" + Cfg.gameId
    }),
    App.View.extend({
        //容器标识
        container: container,

        //视图渲染回调函数定义
        render: function(dlist){
            $.each(dlist,function(i,dobj){
                dobj.alink = "article.html?id=" + dobj.id;
                dobj.title = !dobj.title ? '' :dobj.title.replace(/^《刀塔英雄》/, '');
            });
            console.log('load', dlist);
            this.container.append(Template(guideTpl)({"dataList": dlist}));
            window.slipjs.refresh();
        }
    })
);

App.Requester.init({
    container: container
    // oneTime:true,
});
App.Requester.tigger();